﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using log4net;
using log4net.Config;
using System.Windows.Threading;
using Davian.BLL;
using Davian.Model;
using Npgsql;

namespace Davian
{
    /// <summary>
    /// Interaction logic for Login.xaml
    /// </summary>
    public partial class Login : Window
    {
        private DispatcherTimer dispatcherTimer = null;

        public Login()
        {
            InitializeComponent();
            // Initialize log4net
            XmlConfigurator.Configure(new System.IO.FileInfo(Constant.LOG_CONFIG));
            InitializeDispatcherTimer();
        }

        private void InitializeDispatcherTimer()
        {
            dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 10);
            dispatcherTimer.Start();
        }

        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
        }

        private void button1_Click()
        {
            Mail objMail = new Mail();
            objMail.Send();
            /*
            if (flg)
            {
                dispatcherTimer.Stop();
                flg = false;
                MessageBox.Show("Stop !");
            }
            else
            {
                dispatcherTimer.Start();
                flg = true;
                MessageBox.Show("Start !");
            }
            */
        }

        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            WpfDrawing obj = new WpfDrawing();
            this.Hide();
            obj.ShowDialog();
            this.Show();
            /*
            SysXml sysXml = new SysXml();
            Postgresql objDb = sysXml.ReadPostgresql();
            MessageBox.Show(objDb.ConnectionString);
            NpgsqlConnection conn = new NpgsqlConnection(objDb.ConnectionString);
            conn.Open();
            NpgsqlCommand command = new NpgsqlCommand("select count(*) from sys_ems;", conn);
            try{
                NpgsqlDataReader dr = command.ExecuteReader();
                while (dr.Read())
                {
                    for (int i = 0; i < dr.FieldCount; i++)
                    {
                        Console.Write("{0} \t", dr[i]);
                    }
                }
            }catch(Exception ex){
            }finally
            {
                conn.Close();
            }*/
        }

        private void btnReset_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}
